// 一些自己的方法

// 修改部分数据为*
export const formatData = (data, startIndex, endIndex) => {
  data.slice(startIndex, endIndex)
  if (data.length < 9) {
    return data
  } else {
    return data.slice(0, startIndex) + '****' + data.slice(endIndex)
  }
}

// 提示框
export const showToast = (data) => {
  uni.showToast({
    title: data,
    icon: 'none',
    duration: 2000
  })
}
// 格式化日期
export const formatDate = (data) => {
  return data.slice(0, 4) + ' 年 ' + data.slice(5, 7) + ' 月 ' + data.slice(8, 10) + ' 日 '
}
// 获得并格式化当前日期
export const getNowFormatDate = () => {
  var date = new Date()
  var seperator1 = '-'
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var strDate = date.getDate()
  if (month >= 1 && month <= 9) {
    month = '0' + month
  }
  if (strDate >= 0 && strDate <= 9) {
    strDate = '0' + strDate
  }
  var currentdate = year + seperator1 + month + seperator1 + strDate
  return currentdate
}
// 获得当前时间下一个年份的下一天
export const getNextYear = () => {
  const curDate = new Date()
  var nextDate = new Date(curDate.getTime() + 24 * 60 * 60 * 1000) // 后一天
  var seperator1 = '-'
  var year = nextDate.getFullYear()
  var month = nextDate.getMonth() + 1
  var strDate = nextDate.getDate()
  if (month >= 1 && month <= 9) {
    month = '0' + month
  }
  if (strDate >= 0 && strDate <= 9) {
    strDate = '0' + strDate
  }
  var currentdate = (year + 1) + seperator1 + month + seperator1 + strDate
  return currentdate
}
// 抽象显示动画
export const extractionAnimation = (time, effect) => {
  return uni.createAnimation({
    duration: time || 400, // 动画的持续时间 默认400ms   数值越大，动画越慢   数值越小，动画越快
    timingFunction: effect || 'ease' // 动画的效果 默认值是linear
  })
}
